package com.story.modular.app.service;

import com.qiniu.common.QiniuException;
import org.json.JSONException;
import org.springframework.web.bind.annotation.ExceptionHandler;

import javax.security.auth.message.AuthException;
import java.io.File;
import java.io.InputStream;

/**
 * @author Administrator
 * @decription 七牛云图片上传服务
 * @Date 2017-12-20 16:59
 */
public interface QiniuService {

    /**
     * 通过文件路径上传文件，一般是服务器本地
     * @param localFile
     * @return
     * @throws QiniuException
     */
    public String uploadFile(String localFile) throws QiniuException;

    /**
     * 通过文件上传，可以是远程上传
     * @param file
     * @param fileType
     * @return
     * @throws QiniuException
     */
    public String uploadFile(File file,String fileType) throws QiniuException;

    /**
     * 通过流上传
     * @param key
     * @param content
     * @return
     * @throws QiniuException
     */
    public String upload(String key,String content) throws QiniuException;

    /**
     * 通过流上传
     * @param key
     * @param content
     * @return
     * @throws QiniuException
     */
    public String upload(String key, InputStream content) throws QiniuException;

    /**
     * 获得下载地址(公有文件)
     * @param filename
     * @return
     * @throws Exception
     */
    public String getDownloadFileUrl(String filename) throws Exception;

    /**
     * 获得下载地址（私有的）
     * @param filename
     * @return
     * @throws Exception
     */
    public String getPrivateDownloadFileUrl(String filename) throws Exception;

    /**
     * 删除文件
     * @param filename
     */
    public void deleteFile(String filename) throws QiniuException;

    /**
     * 获得上传凭证，主要应用于客户端直传
     * @return
     * @throws AuthException
     * @throws JSONException
     */
    public String getUpToken();


}
